#include "EmbryoIndividualDisplay.h"

#include "../../../qt/Logger.h"

/*
	EmbryoIndividualDisplay
*/

/*	public	*/

EmbryoIndividualDisplay::EmbryoIndividualDisplay(
	int worldWidth,
	int worldHeight,
	const EmbryoIndividual& individual,
	int developmentalIterations) :
	_development(worldWidth, worldHeight, individual, developmentalIterations),
	_palette() {}

void EmbryoIndividualDisplay::run() {
	/* update display */
	updateDisplay();

	int iteration = 0;
	while(!_development.isFinished()) {
		Logger::info(QString("Developmental iteration %1").arg(iteration));

		/* develop */
		_development.runOnce();

		/* display */
		updateDisplay();

		++iteration;
	}

	while(true) {
		updateDisplay();
	}
}

void EmbryoIndividualDisplay::setPalette(Palette const& palette) {
	_palette = &palette;
}

/*	protected	*/

World const& EmbryoIndividualDisplay::getWorld() {
	return _development.getWorld();
}

Palette const& EmbryoIndividualDisplay::getPalette() const {
	return *_palette;
}

